package com.wanggsx.library.util;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class UtilsDate {

    /**
     * 获取近7天的日期
     * */
    public static List<String> getNearDateStrList(boolean isNeedYear){
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        List<String> list = new ArrayList<>();
        SimpleDateFormat formater;
        if (isNeedYear){
             formater = new SimpleDateFormat("yyyy.MM.dd");
        }else{
             formater = new SimpleDateFormat("MM.dd");
        }
        calendar.add(Calendar.DATE,-3);
        for (int i=0;i<=6;i++){
            list.add(formater.format(calendar.getTime()));
            calendar.add(Calendar.DATE,1);
        }
        return list;
    }

}
